package org.feng.service;

import lombok.extern.slf4j.Slf4j;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * TODO
 *
 * @author feng
 */
@Service
@Slf4j
public class OkHttpService {

    @Resource
    private OkHttpClient okHttpClient;

    public final static String X_WWW_FORM_URLENCODED = "application/x-www-form-urlencoded";

    public final static String CONTENT_TYPE = "Content-Type";


    public final static MediaType X_WWW_FORM_URLENCODED_MEDIA_TYPE = MediaType.get(X_WWW_FORM_URLENCODED);

    public Response newCall(Request request) throws IOException {
        return okHttpClient.newCall(request).execute();
    }
}
